package com.example.cor.chain;

import com.example.cor.filter.Filter;

import javax.servlet.Servlet;

public class ApplicationFilterChainFactory {


    public static FilterChain createFilterChain(Servlet servlet, Filter... filters) {
        if (servlet == null) {
            throw new NullPointerException("servlet must not be null");
        }

        FilterChain chain = new ApplicationFilterChain();
        //set target
        chain.setTarget(servlet);
        // add filter
        for (Filter filter : filters) {
            chain.addFilter(filter);
        }

        return chain;
    }


}
